//接口

export {};

// 接口类型约束的 ,规范

interface Post {
  name: string;
  age: number;
  readonly sex?: string; // readonly 只读属性
}

function fn(post: Post) {
  // post.sex = "男";
  return `${post.name} is ${post.age}`;
}

fn({
  name: "zhangsan",
  age: 18,
  // sex: "女",
});

// --------------

// 动态属性 基本无用

interface Cache {
  [prop: number]: string;
}

let cache: Cache = {};

cache[0] = "foo";
